﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace 桌面视频录制
{
    [Serializable]
    public class DrawEraser : DrawRectangle
    {
        private List<Point> pointList = new List<Point>();
        public DrawEraser(Point leftUpPoint) 
        {
            this.pointList.Add(leftUpPoint);
        }
        public override void Draw(System.Drawing.Graphics g)
        {
            Brush brush = new SolidBrush(this.PenColor);
            for (int i = 0; i < pointList.Count; i++)
            {
                g.FillRectangle(brush, pointList[i].X, pointList[i].Y, 5, 10);
            }
            brush.Dispose();
            brush = null;
        }
        public override void MouseMove(System.Windows.Forms.MouseEventArgs e)
        {
            this.pointList.Add(e.Location);
        }
        public override bool JudgeIsSelected(System.Windows.Forms.MouseEventArgs e)
        {
            return false;
        }
        public override bool JudgeIsInControlRegion(System.Windows.Forms.MouseEventArgs e)
        {
            return false;
        }
        public override void MoveLocation(System.Windows.Forms.MouseEventArgs e)
        {
            int dx = e.X - this.MouseDownPoint.X;
            int dy = e.Y - this.MouseDownPoint.Y;
            this.MouseDownPoint = new Point(e.X, e.Y);
            for (int i = 0; i < pointList.Count; i++)
            {
                pointList[i] = new Point(pointList[i].X + dx, pointList[i].Y + dy);
            }
        }
        public override void ChangeSize(System.Windows.Forms.MouseEventArgs e)
        {

        }
        public override void DrawControlPoint(Graphics g)
        {

        }
        public override string ToString()
        {
            string printMsg = "[橡皮(" + this.PenColor.ToString() + ")]->[ID:" + this.Id + "]";
            return printMsg;
        }
        public override string GetDrawObjectMsg()
        {
            string drawObjectMsg = "橡皮->填充颜色[" + this.PenColor.ToString() + "],样本点数:" + pointList.Count + "个";
            return drawObjectMsg;
        }
        public override bool IsAllInRectangle(Region region)
        {
            foreach (Point point in pointList)
            {
                if (region.IsVisible(point) == false)
                    return false;
            }
            return true;
        }
    }
}
